# #Lagos download script
LAGOSNE::lagosne_get(dest_folder = LAGOSNE:::lagos_path())
#Load in lagos
lagos <- lagosne_load()
#Grab the lake centroid info
lake_centers <- lagos$locus
#Look at the column names
#names(lake_centers)
#Look at the structure
#str(lake_centers)
#View the full dataset
#View(lake_centers %>% slice(1:100))
#st_as_sf, takes table and makes into spatial objects
spatial_lakes <- st_as_sf(lake_centers,coords=c('nhd_long','nhd_lat'),
crs=4326) %>% #crs is projection system. diff codes
st_transform(2163) #transforming projection for map view
#Subset for plotting
subset_spatial <- spatial_lakes %>%
slice(1:100)
subset_baser <- spatial_lakes[1:100,]
#Dynamic mapviewer
mapview(subset_spatial)
states <- us_states()
#Plot all the states to check if they loaded
#mapview(states)
minnesota <- states %>%
filter(name == 'Minnesota') %>%
st_transform(2163)
#Subset lakes based on spatial position
minnesota_lakes <- spatial_lakes[minnesota,]
#Plotting the first 1000 lakes
minnesota_lakes %>%
arrange(-lake_area_ha) %>%
slice(1:1000) %>%
mapview(.,zcol = 'lake_area_ha')
#filtering out the states of interest
Iowa <- states %>%
filter(name == 'Iowa') %>%
st_transform(2163)
Illinois <- states %>%
filter(name == 'Illinois') %>%
st_transform(2163)
#combining the two states and mapping them
maps <- rbind(Iowa,Illinois)
mapview(maps)
iowa_lakes<-spatial_lakes[Iowa,]
illinois_lakes <- spatial_lakes[Illinois,]
A: There are 4,644 lakes in Iowa, and 11,822 lakes in Illinois for a combined total of 16,466 lakes. Minnesota has 29,038 lakes, almost double the amount in Iowa and Illinois.
iowa_size <- iowa_lakes %>%
ggplot(aes(x=lake_area_ha))+
geom_histogram(bins=20,
fill="cadetblue3",
color= "lightblue3",
alpha=0.5)+
scale_x_log10()+
theme_few()+
labs(x= 'Area (ha)', y= 'Count',title="Iowa Lake Size Histogram")
illinois_size <- illinois_lakes %>%
ggplot(aes(x=lake_area_ha))+
geom_histogram(bins=20,
fill="cadetblue3",
color= "lightblue3",
alpha=0.5)+
scale_x_log10()+
theme_few()+
labs(x= 'Area (ha)', y= 'Count',title="Illinois Lake Size Histogram")
ggarrange(iowa_size,illinois_size, ncol=1, nrow=2)
Iowa_Illinois_lakes <- rbind(iowa_lakes,illinois_lakes)
Iowa_Illinois_lakes %>%
arrange(-lake_area_ha) %>%
slice(1:1000) %>%
mapview(.,zcol='lake_area_ha')
A: A dataset with lake inflows and outflows would be beneficial in understanding how much water moves through the system and could potentially bypass remote sensing for maximum and average depth.